import requests
from bs4 import BeautifulSoup
url = 'http://www.netbian.com/mei/'
header={
    "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Edg/120.0.0.0",
}
res = requests.get(url,headers=header)
res.encoding='gbk'
soup = BeautifulSoup(res.text,'html.parser')
listDiv = soup.select('#main .list')[0]
imgList = listDiv.find_all('img')
for img in imgList:
    if 'alt' not in img.attrs:
        continue
    imgRes=requests.get(img['src'],headers=header)
    print(imgRes.content)
    open(f'Images/{img["alt"]}.jpg','wb').write(imgRes.content)
print('抓取完成')